'use strict';

const {getAccessToken} = require("wx-common");
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	
	const access_token = await getAccessToken();
	
	const res = await uniCloud.httpclient.request("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + access_token,{
		method:"POST",
		headers:{
			"Content-Type": "application/json"
		},
		data:{
			scene: event.scene,//小程序的场景标签
			page: event.page//长按小程序码之后直接跳转到指定页面，不传默认跳转首页
		}
	})
	
	//返回数据给客户端
	return res.data;
};
